﻿Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports System.Xml

Public Class rss
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Clear()
        Response.ContentType = "application/rss+xml;"
        Dim rssFeed As New XmlTextWriter(Response.OutputStream, Encoding.UTF8)
        rssFeed.WriteStartDocument()
        rssFeed.WriteStartElement("rss")
        rssFeed.WriteAttributeString("version", "2.0")
        rssFeed.WriteStartElement("channel")
       

        Dim sql As String = "select TOP 5 * from Albums ORDER BY ID DESC"
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("SingerProfileConStr").ConnectionString)
        Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
        conn.Open()
        Dim dr As OleDbDataReader = cmd.ExecuteReader()
        rssFeed.WriteElementString("title", "Robbie Williams New Albums")
        rssFeed.WriteElementString("link", "List.aspx")
        rssFeed.WriteElementString("description", "WelCome to Site. Check all of his Latest Albums.")
        Do While dr.Read()
            rssFeed.WriteStartElement("item")
            rssFeed.WriteElementString("title", dr("Album_Name").ToString())
            rssFeed.WriteElementString("link", "Details.aspx?ID=" + dr("ID").ToString())
            rssFeed.WriteElementString("description", dr("Description").ToString())
            rssFeed.WriteEndElement()

        Loop
        dr.Close()
        conn.Close()
        conn.Dispose()

        rssFeed.WriteEndElement()
        rssFeed.WriteEndElement()
        rssFeed.WriteEndDocument()
        rssFeed.Flush()
        rssFeed.Close()
        Response.End()
    End Sub

End Class